﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;

namespace LUStationery.DAO
{
    public class RequisitionFormDAO
    {
        SqlConnection cn;
        SqlCommand cmd;
        public RequisitionFormDAO() 
        {
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        }

        public IDataReader getRequisitionFormsByIDs(HashSet<string> rfIDs)
        {
            string inset = "(0,";
            
            foreach (string id in rfIDs)
            {
                inset = inset + "'" + id + "',";
            }
            inset = inset.Remove(inset.Length - 1);
            inset = inset + ")";

            cmd = new SqlCommand("Select * from requisition_form where requisition_form_id in "+inset, cn);
            //cmd.Parameters.Add("@requisitionFormIDs", SqlDbType.VarChar).Value = inset;
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }
       //ZHONG YUE\\
        public IDataReader getRemarkByRequisitionFormID(string requisitionFormID)
        {

            cmd = new SqlCommand("Select * from requisition_form where requisition_form_id=@requisitionFormID", cn);
            cmd.Parameters.Add("@requisitionFormID", SqlDbType.VarChar).Value = requisitionFormID;
            cn.Open();
            IDataReader idr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return idr;
        }
    }
}
